<script setup>
import {b} from '@/utils/system.js'
import {ApiGetUserInfo} from '@/api/user.js'
import { ref } from 'vue';

// 用户信息
const userInfo=ref()
const getUserInfo=async()=>{
  const res =await ApiGetUserInfo()
  userInfo.value=res.data
}
getUserInfo()

// 我的下载
const onDownLoad=()=>{
  uni.navigateTo({
    url:`/subpackage/classlist/classlist?type=download&name=我的下载`
  })
}
// 我的评分
const onScore=()=>{
  uni.navigateTo({
    url:`/subpackage/classlist/classlist?type=score&name=我的评分`
  })
}

</script>

<template>
  <view class="user-container pagebg" v-if="userInfo">
    <view :style="{height:b+'px'}"></view>
    <!-- 个人信息 -->
    <view class="header">
         <view class="avatar">
           <image src="../../static/images/xxmLogo.png" mode="aspectFill"></image>
         </view> 
         <view class="ip">{{userInfo.IP}}</view>
          <view class="city">来自：{{userInfo.address.city || userInfo.address.province || userInfo.address.county}}</view>
    </view>
    
    <!-- 个人的功能 -->
    <view class="setion">
      <view class="row" @click="onDownLoad">
        <div class="left">
          <view class="icon"><uni-icons color="#28b389" type="cloud-download-filled" size="20"></uni-icons></view>
          <view class="text">我的下载</view>
        </div>
        <div class="right">
          <view class="text">{{userInfo.downloadSize}}</view>
          <view class="icon"><uni-icons color="#aaa" type="right" size="15"></uni-icons></view>
        </div>
      </view>
      <view class="row" @click="onScore">
        <div class="left">
          <view class="icon"><uni-icons color="#28b389" type="star-filled" size="20"></uni-icons></view>
          <view class="text">我的评分</view>
        </div>
        <div class="right">
          <view class="text">{{userInfo.scoreSize}}</view>
          <view class="icon"><uni-icons color="#aaa" type="right" size="15"></uni-icons></view>
        </div>
      </view>
      <view class="row">
        <div class="left">
          <view class="icon"><uni-icons color="#28b389" type="chatboxes-filled" size="20"></uni-icons></view>
          <view class="text">联系客服</view>
        </div>
        <div class="right">
          <view class="text">0</view>
          <view class="icon"><uni-icons color="#aaa" type="right" size="15"></uni-icons></view>
        </div>
      </view>
      <button open-type="contact">联系客服</button>
    </view>
    <!-- 第二部分 -->
    <view class="setion">
      <view class="row">
        <div class="left">
          <view class="icon"><uni-icons color="#28b389" type="notification-filled" size="20"></uni-icons></view>
          <view class="text">订阅更新</view>
        </div>
        <div class="right">
          <view class="icon"><uni-icons color="#aaa" type="right" size="15"></uni-icons></view>
        </div>
      </view>
      <view class="row">
        <div class="left">
          <view class="icon"><uni-icons color="#28b389" type="flag-filled" size="20"></uni-icons></view>
          <view class="text">常见问题</view>
        </div>
        <div class="right">
          <view class="icon"><uni-icons color="#aaa" type="right" size="15"></uni-icons></view>
        </div>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
  .user-container{
    // 个人信息
    .header{
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 80rpx 20rpx;
      .avatar{
        width: 160rpx;
        height: 160rpx;
        border-radius: 50%;
        overflow: hidden;
        margin-bottom: 20rpx;
        image{
          width: 100%;
          height: 100%;
        }
      }
      .ip{
        font-size: 44rpx;
        color: #333;
        margin-bottom: 10rpx;
      }
      .city{
        font-size: 28rpx;
        color: #aaa;
      }
    }
  // 个人功能
    .setion{
      width: 690rpx;
      margin: 50rpx auto;
      border-radius: 10rpx;
      border: 1px solid #eee;
      box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.05);
      position: relative;
      button{
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        opacity: 0;
      }
      .row{
        width: 100%;
        padding: 20rpx 30rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
        &:last-child{
          border-bottom: 0;
        }
        .left{
          display: flex;
          justify-content: space-between;
          align-items: center;
          .icon{
            margin-right: 15rpx;
          }
          text{
           color: #666;
          }
        }
        .right{
          display: flex;
          justify-content: space-between;
          align-items: center;
          .text{
            font-size: 28rpx;
            color: #aaa;
          }
        }
      }
    }
  }
  
</style>
